﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ProfileTest.cs" company="">
//   
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Tests
{
    using System.Collections.Generic;

    using ExecutionTool.Profile;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class ProfileTest
    {
        #region Public Methods and Operators

        [TestMethod]
        public void CanCreateProfileData()
        {
            const string Profile1Name = "profile1";
            const string Profile2Name = "profile2";

            // arrange
            var p1 = new Profile
                {
                    Name = Profile1Name, 
                    Source =
                        new SqlAzureLocation
                            {
                               ServerNamePrefix = "serverNamePrefix", UserName = "username", Password = "password", DatabaseName = "database" 
                            }, 
                    TargetAzureStorage = new AzureStorageLocation(), 
                    TargetSqlAzureVerification = new SqlAzureLocation(), 
                    TargetOnPremisesLocation = new OnPremisesLocation(), 
                    Orchestration = new Orchestration()
                };

            var p2 = new Profile
                {
                    Name = Profile2Name, 
                    Source =
                        new SqlAzureLocation
                            {
                               ServerNamePrefix = "serverNamePrefix", UserName = "username", Password = "password", DatabaseName = "database" 
                            }, 
                    TargetAzureStorage = new AzureStorageLocation(), 
                    TargetSqlAzureVerification = new SqlAzureLocation(), 
                    TargetOnPremisesLocation = new OnPremisesLocation(), 
                    Orchestration = new Orchestration()
                };

            var profiles = new List<Profile> { p1, p2 };

            // action
            ProfileFacade.SaveProfiles(profiles);
            profiles = ProfileFacade.LoadProfiles();

            // assertion
            Assert.IsNotNull(profiles);
            Assert.AreEqual(2, profiles.Count);
            Assert.AreEqual(Profile1Name, profiles[0].Name);
            Assert.AreEqual(Profile2Name, profiles[1].Name);
        }

        #endregion
    }
}
